package com.yshkj.payment.dto;

import com.yshkj.payment.entity.medicinal.Producer;
import com.yshkj.payment.entity.medicinal.SaleRecordItem;
import com.yshkj.payment.entity.medicinal.Spec;
import lombok.Data;

/**
 * 药品销售dto
 * Created by 唐旭 on 2016/10/6.
 */
@Data
public class SpecSaleDto {
    private String uuid;
    //规格名称
    private String name;
    //销售价格
    private String outPrice;
    //库存数量
    private int count;
    //销售数量
    private int saleCount = 1;
    //物品编码
    private String code;
    //药品名称
    private String medicinalName;
    //生产厂家
    private String producerName;

    public SpecSaleDto() {
    }

    public SpecSaleDto(Spec spec) {
        this.uuid = spec.getUuid();
        this.name = spec.getName();
        if (spec.getOutPrice() != null) {
            this.outPrice = spec.getOutPrice().toString();
        }
        this.count = spec.getCount();
        this.code = spec.getCode();
        this.medicinalName = spec.getMedicinal().getName();
        Producer producer = spec.getMedicinal().getProducer();
        if (producer != null) {
            this.producerName = producer.getName();
        }
    }

    public void update(SaleRecordItem item) {
        item.setCount(this.saleCount);
    }
}
